<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:zj="http://www.zju.edu.cn" exclude-result-prefixes="zj">
  <xsl:template name="zj:Search">
    <xsl:variable name="zj:Searches" select="$zj:XmlData/Toolkit/zj:Table/List/zj:Field[zj:Extension/@Search='title']"/>
    <xsl:if test="count($zj:Searches) &gt; 0">
      <form name="frmData" onsubmit="return false;">
        <table width="100%" border="0" cellspacing="0" cellpadding="2" class="datagrid" id="{$zj:XmlData/Toolkit/zj:Table/@TableName}">
          <tr>
            <td class="td-right">
              <xsl:apply-templates select="$zj:Searches" mode="zj:Search"/>
              <xsl:call-template name="zj:OtherSearches"/>
              <nobr>
                <input name="query" type="checkbox" class="noborder" value="1">
                  <xsl:variable name="CheckValue" select="$zj:Toolkit/_CONDITION/query"/>
                  <xsl:choose>
                    <xsl:when test="boolean($CheckValue)">
                      <xsl:if test="$CheckValue=1">
                        <xsl:attribute name="checked"/>
                      </xsl:if>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:attribute name="checked"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </input>精确查询
                <!--<input type="submit" name="xml" value="搜索" class="clsButtonFacebt" onclick="Post2()"/>-->
               
                <a href="#" class="l-btn"  onclick="Post2()" >
                  <span class="l-btn-left">
                    <span class="l-btn-text">搜索</span>
                  </span>
                </a>
              </nobr>
            </td>
          </tr>
        </table>
      </form>
    </xsl:if>
  </xsl:template>
  <xsl:template match="zj:Field" mode="zj:Search">
    <xsl:variable name="HtmlCtrl" select="zj:HtmlCtrl/@HtmlCtrl"/>
    <xsl:variable name="Condition" select="$zj:Toolkit/_CONDITION"/>
    <xsl:variable name="Value" select="$Condition/*[local-name()=current()/zj:FieldName]"/>
    <xsl:choose>
      <xsl:when test="$HtmlCtrl='Text'">
        <nobr>
          <xsl:value-of select="zj:DisplayName"/>
          <img height="1" src="../images/empty.gif" width="5"/>
          <input type="text" name="{zj:FieldName}" id="{zj:FieldName}" value="{$Value}"/>
          <xsl:choose>
            <xsl:when test="@DataType='Date'">
              <img name="popcal" align="absmiddle" src="../images/look_day.gif" width="18" height="17" border="0" onclick="gfPop.fPopCalendar(frmData.{zj:FieldName});return false;"/>
            </xsl:when>
            <xsl:when test="@DataType='DateTime'">
              <img name="popcal" align="absmiddle" src="../images/look_day.gif" width="18" height="17" border="0" onclick="gfPop4.fPopCalendar(frmData.{zj:FieldName});return false;"/>
            </xsl:when>
          </xsl:choose>
          <xsl:if test="zj:Extension/@Span='true'">
            <xsl:variable name="NewName" select="concat(zj:FieldName, 'END')"/>
          至 <input type="text" name="{$NewName}" id="{$NewName}" value="{$Condition/*[local-name()=$NewName]}"/>
            <xsl:choose>
              <xsl:when test="@DataType='Date'">
                <img name="popcal" align="absmiddle" src="../images/look_day.gif" width="18" height="17" border="0" onclick="gfPop.fPopCalendar(frmData.{$NewName});return false;"/>
              </xsl:when>
              <xsl:when test="@DataType='DateTime'">
                <img name="popcal" align="absmiddle" src="../images/look_day.gif" width="18" height="17" border="0" onclick="gfPop4.fPopCalendar(frmData.{$NewName});return false;"/>
              </xsl:when>
            </xsl:choose>
          </xsl:if>
          <img height="1" src="../images/empty.gif" width="10"/>
        </nobr>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='Combo'">
        <nobr>
          <xsl:value-of select="zj:DisplayName"/>
          <img height="1" src="../images/empty.gif" width="5"/>
          <xsl:variable name="CodeTable" select="$zj:Toolkit/*[local-name()=current()/zj:CodeTable]"/>
          <select name="{zj:FieldName}" id="{zj:FieldName}" size="1">
            <xsl:call-template name="zj:Attribute">
              <xsl:with-param name="Field" select="."/>
            </xsl:call-template>
            <option value="">
              <xsl:attribute name="selected"/>
            </option>
            <option value="~">--空--</option>
            <xsl:for-each select="$CodeTable">
              <option value="{CODE_VALUE}">
                <xsl:if test="CODE_VALUE=$Value">
                  <xsl:attribute name="selected"/>
                </xsl:if>
                <xsl:value-of select="CODE_NAME"/>
              </option>
            </xsl:for-each>
          </select>
          <img height="1" src="../images/empty.gif" width="10"/>
        </nobr>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='EasySearch'">
        <nobr>
          <xsl:value-of select="zj:DisplayName"/>
          <img height="1" src="../images/empty.gif" width="5"/>
          <!--input type="hidden" name="{zj:FieldName}" id="{zj:FieldName}"/-->
          <input type="text" name="{zj:FieldName}" id="{zj:FieldName}" onchange="KeyUp(this.value, hd{zj:FieldName})" value="{$Value}">
            <xsl:call-template name="zj:Attribute">
              <xsl:with-param name="Field" select="."/>
            </xsl:call-template>
          </input>
          <input type="hidden" name="hd{zj:FieldName}" id="hd{zj:FieldName}" value="{$Condition/*[local-name()=concat('hd', current()/zj:FieldName)]}"/>
          <input type="hidden" name="hd{zj:FieldName}Type" id="hd{zj:FieldName}Type" value="{zj:EasySearch/@RegName}"/>
          <img src="../images/lookup.gif" alt="查询" style="WIDTH: 18px;height=17px;border=0;cursor:hand" align="middle" width="18" height="17" name="Img{zj:FieldName}">
            <xsl:attribute name="onclick">setLastMousePosition(event);<xsl:value-of select="zj:Extension/@ImgClick"/></xsl:attribute>
          </img>
          <img height="1" src="../images/empty.gif" width="10"/>
        </nobr>
      </xsl:when>
      <xsl:when test="$HtmlCtrl='CheckBox'">
        <nobr>
          <xsl:value-of select="zj:DisplayName"/>
          <img height="1" src="../images/empty.gif" width="5"/>
          <select name="{zj:FieldName}" id="{zj:FieldName}" size="1">
            <xsl:call-template name="zj:Attribute">
              <xsl:with-param name="Field" select="."/>
            </xsl:call-template>
            <xsl:variable name="CheckValue">
              <xsl:choose>
                <xsl:when test="zj:Extension/@CheckValue!=''">
                  <xsl:value-of select="zj:Extension/@CheckValue"/>
                </xsl:when>
                <xsl:otherwise>1</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:variable name="UnCheckValue">
              <xsl:choose>
                <xsl:when test="zj:Extension/@UnCheckValue!=''">
                  <xsl:value-of select="zj:Extension/@UnCheckValue"/>
                </xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <option value="">
              <xsl:attribute name="selected"/>
            </option>
            <option value="{$CheckValue}">
              <xsl:if test="$CheckValue=$Value">
                <xsl:attribute name="selected"/>
              </xsl:if>是</option>
            <option value="{$UnCheckValue}">
              <xsl:if test="$UnCheckValue=$Value">
                <xsl:attribute name="selected"/>
              </xsl:if>否</option>
          </select>
          <img height="1" src="../images/empty.gif" width="10"/>
        </nobr>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="Page" mode="zj:Processbar">
    <table width="800" cellSpacing="0" cellpadding="0" align="center" border="0" style="MARGIN-LEFT: auto; MARGIN-RIGHT:auto;position:absolute;left:145" id="pTable">
      <tr>
        <TD style="CURSOR: pointer" width="25" title="首页" align="right">
          <xsl:if test="$zj:CurPage>1">
            <xsl:attribute name="onclick">incr_page('1');</xsl:attribute>
          </xsl:if>
          <IMG height="16" src="../images2/gw_cmt_006.gif" width="23" border="0"/>
        </TD>
        <TD id="pZone" vAlign="top" background="../images2/gw_cmt_007.gif" width="600" onclick="pmouseDown(pZone)">
          <div id="pBox" style="position:absolute;left:170;width:9;height:17">
            <div style="position:absolute;width:9;height:17;background-image:url(../images2/gw_cmt_0081.gif)" onmousedown="showTip(pBox)" onmouseout="hideTip();" onmouseover="showTip2(pBox)">
					</div>
            <div id="title" style="position:relative;width:40;height:20;left:0;top:20;background-color:#FFFF66;display:none" align="center"/>
          </div>
          <input type="hidden" id="hidListHeadUrl" value="{$zj:ListHeadUrl}"/>
          <input type="hidden" id="hidListOrder" value="{$zj:ListOrder}"/>
        </TD>
        <TD style="CURSOR: pointer" width="25" title="末页" align="left">
          <xsl:if test="$zj:CurPage &lt; TotalPage">
            <xsl:attribute name="onclick">incr_page('<xsl:value-of select="TotalPage"/>');</xsl:attribute>
          </xsl:if>
          <IMG height="16" src="../images2/gw_cmt_005.gif" width="23" border="0"/>
        </TD>
      </tr>
    </table>
    <table>
      <tr>
        <td height="16">
				</td>
      </tr>
    </table>
    <script language="javascript">
		var totalPage;
		var curPage;
		var ListHeadUrl;
		var ListOrder;
		var pZoneWidth;
		var	pZoneLeft;

		function initpageparams_1()
		{
		totalPage = parseInt('<xsl:value-of select="TotalPage"/>');
		curPage=parseInt('<xsl:value-of select="$zj:CurPage"/>');
		ListHeadUrl = document.all("hidListHeadUrl").value;
		ListOrder = document.all("hidListOrder").value;
		pZoneWidth=0;
		pZoneLeft=0;
		}
		<xsl:comment><![CDATA[ 	
		function pmouseDown(obj)
		{
			if(event.x>26)
			{
				var tmp =event.offsetX; 
				if(tmp < 1)
					tmp=1;
				else if(tmp> pZoneWidth)
				{
					tmp = pZoneWidth;
					}
				var div1=tmp/(pZoneWidth/totalPage);
				var div2=parseInt(div1);
				if(div1>div2)
						div2 = div2+1;
				location.href = ListHeadUrl+'&amp;Page='+div2+ ListOrder;
			}
		}
		
		function getWidth()
		{
			if(window.document.body.clientWidth < 625)
				pZoneWidth = 455;
			else
				pZoneWidth = window.document.body.clientWidth-170;
			document.all("pTable").width = pZoneWidth;
			pZoneWidth=pZoneWidth-50;
			document.all("pZone").width = pZoneWidth;
			return pZoneWidth;	
		}
		function incr_page(imgpage)
		{
			var imgurl=ListHeadUrl+'&amp;Page='+imgpage+ ListOrder;
			location.href = imgurl;
		}
				
		function initmouseDown()
		{initpageparams_1();
			pZoneLeft = document.all("pTable").style.pixelLeft;	
			if (totalPage !=0)
				document.all("pBox").style.left=25+(getWidth()/totalPage)*(curPage-1);
			else
				document.all("pBox").style.left=25+(getWidth()/(totalPage+1))*(curPage-1);
			document.all("title").style.display="none";
		}
		initmouseDown();
	
		
		var Obj='',pX=0;

			document.onmouseup=MUp;
			document.onmousemove=MMove;		
		
		function showTip(Object)
		{
			Obj=Object.id;
			document.all("title").innerHTML = "第"+curPage+"页";
			document.all("title").style.Left = event.x;
			document.all("title").style.display='';
			document.all(Obj).setCapture()
			pX=event.x-document.all(Obj).style.pixelLeft+25;
		}
		function showTip2(Object)
		{
			Object.title = "第"+curPage+"页";
		}
		function MMove(){
		if(Obj!=''){
			if((event.x-pX) < 0)
				document.all(Obj).style.pixelLeft=25;
			else if((event.x-pX) >pZoneWidth) 
				document.all(Obj).style.pixelLeft=pZoneWidth+25;
			else
				document.all(Obj).style.pixelLeft=event.x-pX+25;
					var div1=(document.all(Obj).style.pixelLeft-25)/((pZoneWidth)/totalPage);
					var div2=parseInt(div1);
					if(div1>div2)
						div2 = (parseInt(div2)+1);
					if(div2>totalPage)
						div2 = totalPage;
			document.all("title").innerHTML = "第"+div2+"页";
			}
		}
		function MUp()
		{
			if(Obj!='')
			{
					document.all(Obj).releaseCapture();		
					var div1=(document.all(Obj).style.pixelLeft-25)/((pZoneWidth)/totalPage);
					var div2=parseInt(div1);
					if(div1>div2)
						div2 = (parseInt(div2)+1);
					if(div2>totalPage)
						div2 = totalPage;
					obj='';
					if(div2<1) div2 = 1;
					document.all("pZone").onclick='';
					document.all("title").style.display='none';
					location.href = ListHeadUrl+'&amp;Page='+div2.toString()+ ListOrder;
			}
		}
		
		function hideTip(){document.all("pBox").title = "";}
		
    function searchend()
    {
		initmouseDown();
    }		
			]]></xsl:comment>
    </script>
  </xsl:template>
  <xsl:template name="zj:OtherSearches"/>
  <xsl:template name="zj:PageTitle">
    <xsl:call-template name="zj:LittleTitle">
      <xsl:with-param name="Name" select="concat('浏览', $zj:XmlData/Toolkit/@Desc)"/>
    </xsl:call-template>
  </xsl:template>
</xsl:stylesheet>
